<?php

namespace zhtfrontend\models\datas;

use Yii;
use yii\helpers\ArrayHelper;
use common\components\behaviors\UpdateCacheBehavior;

/**
 * This is the model class for table "{{%department}}".
 *
 * @property integer $id
 * @property integer $site_id
 * @property string $name
 * @property string $description
 * @property string $created_at
 * @property string $group_id
 */
class Department extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%department}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['site_id'], 'required'],
            [['site_id'], 'integer'],
            [['description'], 'string'],
            [['name'], 'string', 'max' => 255],
            [['created_at'], 'string', 'max' => 20],
            [['group_id'], 'string', 'max' => 6]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('zhtfrontend', '自动编号'),
            'site_id' => Yii::t('zhtfrontend', '广场ID'),
            'name' => Yii::t('zhtfrontend', '部门名称'),
            'description' => Yii::t('zhtfrontend', '部门描述'),
            'created_at' => Yii::t('zhtfrontend', '部门创建时间'),
            'group_id' => Yii::t('zhtfrontend', '组ID'),
        ];
    }

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            [
                'class' => UpdateCacheBehavior::className(),
                'cacheName' => 'department',
            ],
        ]);
    }
}
